package org.dromara.exam.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.dromara.common.mybatis.annotation.DataColumn;
import org.dromara.common.mybatis.annotation.DataPermission;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.exam.domain.entity.ExamTemplate;
import org.dromara.exam.domain.vo.ExamTemplateVo;
import org.dromara.exam.domain.dto.TemplateCount;
import org.dromara.exam.domain.dto.TemplateTypeCount;

import java.util.List;
import java.util.Map;

/**
 * 题目Mapper接口
 *
 * @author xiyin321
 * @date 2024-04-11
 */
public interface ExamTemplateMapper extends BaseMapperPlus<ExamTemplate, ExamTemplateVo> {

    /**
     * 查询题目分页列表
     *
     * @param page      分页对象
     * @param wrapper   查询条件
     * @param tagIds    标签ID列表
     * @param matchMode 标签匹配模式
     * @return Page<ExamTemplateVo>
     */
    @DataPermission({
        @DataColumn(key = "userName", value = "q.create_by"),
        @DataColumn(key = "deptName", value = "q.create_dept")
    })
    Page<ExamTemplateVo> selectQuestionVoPage(
        @Param("page") Page<ExamTemplate> page, @Param(Constants.WRAPPER) Wrapper<ExamTemplate> wrapper,
        @Param("tagIds") List<Long> tagIds, @Param("matchMode") Integer matchMode);

    /*挑选题目*/
    List<ExamTemplateVo> pickTemplateList(Long repoId, List<String> questionTypes, List<String> tags);

    /**
     * 根据repoId查询题目数量
     * @param repoId 题库ID
     * @return 题目类型统计列表
     */
     List<TemplateTypeCount> queryTemplateTypeCounts(List<Long> repoIds);

    List<TemplateCount> queryVoCounts(List<Long> repoIds);
}
